package org.dream.ui.chart;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JPanel;

import org.dream.ui.MainFrame;
import org.dream.util.PropUtil;

/**
 * 
 * @author qiuriyuchen E-mail:panpan_001@126.com
 */
public class FibonacciDialog extends JDialog {

	public FibonacciDialog(Frame owner, boolean modal, int x, int y) {
		super(owner, null, modal);
		this.setContentPane(new ViewSetPanel());
		this.setLocation(x, y);
		this.setSize(300, 200);
		this.setTitle("菲波纳奇");
		this.setVisible(true);

	}

	class ViewSetPanel extends JPanel {
		JCheckBox daLiangCheckBox = new JCheckBox("0.618");
		JCheckBox turningPointCheckBox = new JCheckBox("转折点");
		JCheckBox delteCheckBox = new JCheckBox("delte");

		public ViewSetPanel() {

			this.add(daLiangCheckBox);
			daLiangCheckBox.setSelected(PropUtil.getPropertyBool("daLiang"));
			daLiangCheckBox.addActionListener(new CheckActionListener());
			this.add(turningPointCheckBox);
			turningPointCheckBox.setSelected(PropUtil
					.getPropertyBool("turningPoint"));
			turningPointCheckBox.addActionListener(new CheckActionListener());
			this.add(delteCheckBox);
			delteCheckBox.setSelected(PropUtil.getPropertyBool("delte"));
			delteCheckBox.addActionListener(new CheckActionListener());

		}

		class CheckActionListener implements ActionListener {
			public void actionPerformed(ActionEvent e) {
				PropUtil.storePropertyBool("daLiang", daLiangCheckBox
						.isSelected());
				PropUtil.storePropertyBool("turningPoint", turningPointCheckBox
						.isSelected());
				PropUtil.storePropertyBool("delte", delteCheckBox.isSelected());
				((MainFrame) FibonacciDialog.this.getOwner()).getCenterPanel()
						.repaint();
			}
		}

	}
}
